import 'dart:io';
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:provider/provider.dart';
import 'package:yzcreator/platform_menus.dart';
import 'theme.dart';
// import 'package:url_launcher/url_launcher.dart';



/// This method initializes macos_window_utils and styles the window.
Future<void> _configureMacosWindowUtils() async {
  const config = MacosWindowUtilsConfig();
  await config.apply();
}

Future<void> main() async{
  if (!kIsWeb) {
    if (Platform.isMacOS) {
      await _configureMacosWindowUtils();
    }
  }
  runApp(YZApp());
}

class YZApp extends StatelessWidget {
  const YZApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => AppTheme(),
      builder: (context, _) {
        final appTheme = context.watch<AppTheme>();
        return MacosApp(
          title: 'YZCreator',
          themeMode: appTheme.mode,
          debugShowCheckedModeBanner: false,
          home: YZMainPage(),
        );
      },
    );
  }
}


class YZMainPage extends StatefulWidget {
  const YZMainPage({super.key});

  @override
  State<YZMainPage> createState() => _YZMainPageState();
}

class _YZMainPageState extends State<YZMainPage> {
  @override
  Widget build(BuildContext context) {
    return PlatformMenuBar(
      menus: menuBarItems(),
      child: MacosWindow(
      
      ),
    );
  }
}